﻿#ifndef CHeader_H
#define CHeader_H

#define A2T QString::fromLocal8Bit
#define FL  __FILE__+(","+QString::number(__LINE__)) 

#define _Q(x) (x).toLocal8Bit().data()                  //QString中含有中文转char * 需要使用toLocal8Bit().data() 
#define _QStr2CharStr(x) x.toStdString().c_str()        //将QString 转化成 char* 字符串
#define _QSClearPoint(x)  QString::number(x.toDouble(), 'f', 0).toStdString().c_str()        //将QString 转化成 char* 字符串 同时去除对应的小数位
#define _QNumStr2UInt(x) (unsigned int)x.toDouble()     //将QString 数值转化成unsigned int
#define _QNumStr2Int(x) (int)x.toDouble()               //将QString 数值转化
#include <QString>
#include <QWidget>
#include <windows.h>


//安全释放指针
#define SAFE_DELETE(p) \
{ \
if (NULL != p) \
{ \
	delete p; \
	p = NULL; \
} \
}

class CHeader
{
	CHeader() {};
	~CHeader() {};
};

/**
* @ Author: 
* @ Description: 任务类型枚举
*/
enum ETaskType
{
	enInterTask,//定时任务类型
	enPerTask,//周期任务类型
	enAtOnceTask//立即执行任务类型
};

/**
* @ Author: W
* @ Description: 周期类型枚举
*/
enum EPeriodType
{
	enCycTwelveHours,//12h
	enCycSixHours,//6h
	enCycFourHours,//4h
	enCycTwoHours,//2h
	enCycOneHours,//1h
	enCycHalfHour//0.5h
};

/**
* @ Author: Gaojia
* @ Description: 设备类型枚举
*/
enum EDevType
{
	enOntology,       //设备本体 PLC
	enSubDev1,        //子设备1 对于机器人来说是云台
	enSubDev2		  //子设备2 对于机器人来说是冲洗设备
};

enum EDevTypeCode
{
	enCO,        //一氧化碳
	enGas,       //可燃气体
	enPM25,      //PM25
	enPM10,      //PM10
	enTemp,	     //温度
	enHum,       //湿度
	enUltrasonic,//超声波
	enCamer,     //图像相机
	enIR,        //红外相机
	enVoice,     //声音传感器
};

class CPolPoint;
class CTaskInfo;
class SCPolItemCom;
class CPolItem;
class CTaskExecInfo;
extern QString createGuid();   //生成Guid函数，返回生成的guid字符串
extern bool setNativeTitleBar(HWND hwnd, COLORREF color);
extern void sysSleepTime(int nMs);   //线程休眠函数
extern int messageBox(int nMsgLevel, QString sMsg);
extern bool sortPoint(CPolPoint* pPoint1, CPolPoint* pPoint2);
extern bool sortPointReverse(CPolPoint* pPoint1, CPolPoint* pPoint2);
extern bool sortItem(SCPolItemCom* pItem1, SCPolItemCom* pItem);
extern bool sortPolItem(CPolItem* pItem1, CPolItem* pItem);
extern bool sortExecInfo(CTaskExecInfo& pExecInfo1, CTaskExecInfo& pExecInfo2);
extern bool sortTaskInfo(CTaskInfo& Info1, CTaskInfo& Info2);
extern QString setUiStyle(QString sName);   //设置样式表 sName样式表名称
extern bool showMsgBox(QWidget* parent, const QString& title, const QString& message, int nType = 0, bool withCancel = false);
#endif